{% extends "blog/base.html" %}
{% block title %}Post Creation{% endblock %}
{% block body %}
    <div class="row">
        <h1 class="text-center">Edit {{ post.title }}</h1>
        <form method="POST" action="{{ url_for('.edit_post', id=post.id) }}">
            {{ form.hidden_tag() }}
            <div class="form-group">
                {{ form.title.label }}
                {% if form.title.errors %}
                    {% for e in form.title.errors %}
                        <p class="help-block">{{ e }}</p>
                    {% endfor %}
                {% endif %}
                {{ form.title(class_='form-control', value=post.title) }}
            </div>
            <div class="form-group">
                {{ form.text.label }}
                {% if form.text.errors %}
                    {% for e in form.text.errors %}
                        <p class="help-block">{{ e }}</p>
                    {% endfor %}
                {% endif %}
                {{ form.text(id="editor", class_='form-control') }}
            </div>
            <input class="btn btn-primary" type="submit" value="Submit">
        </form>
    </div>
{% endblock %}

{% block js %}
<script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script>
<script>
    CKEDITOR.replace('editor');
</script>
{% endblock %}